//
//  LXBaseCell.swift
//  zhibo
//
//  Created by Echo on 16/9/27.
//  Copyright © 2016年 Echo. All rights reserved.
//

import UIKit
import Kingfisher

class LXBaseCell: UICollectionViewCell {
    @IBOutlet weak var onlineBtn: UIButton!
    @IBOutlet weak var iconImageV: UIImageView!
    @IBOutlet weak var nickNameLabel: UILabel!
    
    var anchor : LXAnchor? {
        didSet {
            // 校验anchor是否有值
            guard let anchor = anchor else {return}
            
            var title : String = ""
            if anchor.online >= 10000 {
                title = "\(Int(anchor.online / 10000))万人在线"
            }else {
                title = "\(anchor.online)人在线"
            }
            onlineBtn.setTitle(title, forState: .Normal)
            
            //
            nickNameLabel.text = anchor.nickname
            
            //
            guard let urlStr = NSURL(string: anchor.vertical_src) else {return}
            iconImageV.kf_setImageWithURL(urlStr)
        }
    }

}
